home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / lang / fpcsrc.lha / fpc / compiler / makefile < prev    next >
Makefile  |  1998-09-24  |  13KB  |  550 lines

  1. #
  2. #   $Id: makefile,v 1.6.2.3 1998/08/06 14:27:26 pierre Exp $
  3. #   This file is part of the Free Pascal run time library.
  4. #   Copyright (c) 1993-98 by the Free Pascal Development Team
  5. #
  6. #   Makefile for the Free Pascal Compiler
  7. #
  8. #   See the file COPYING.FPC, included in this distribution,
  9. #   for details about the copyright.
  10. #
  11. #   This program is distributed in the hope that it will be useful,
  12. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15.  
  16. #####################################################################
  17. # Try to determine Operating System
  18. #####################################################################
  19.  
  20. BASEDIR=$(shell pwd)
  21.  
  22. # in linux no : in pathes
  23. ifeq ($(findstring :,$(BASEDIR)),)
  24. inlinux=1
  25. endif
  26.  
  27. # in case pwd is not present on the DOS-OS
  28. ifeq ($(strip $(BASEDIR)),'')
  29. inlinux=
  30. BASEDIR:=.
  31. endif
  32.  
  33. # What compiler to use
  34. ifndef PP
  35. PP=ppc386
  36. endif
  37.  
  38. #####################################################################
  39. # Setup Targets
  40. #####################################################################
  41.  
  42. # what target do we use
  43. # currently dos go32v2 os2 and linux are available
  44. ifdef inlinux
  45. TARGET=linux
  46. else
  47. TARGET=go32v2
  48. endif
  49.  
  50. # What processor do you want to compile for : i386 m68k (case sensitive !!)
  51. ifndef CPU
  52. CPU= i386
  53. # CPU= m68k
  54. endif
  55.  
  56. BUGFIX=YES
  57. export BUGFIX
  58.  
  59. #####################################################################
  60. # Setup Files Directories
  61. #####################################################################
  62.  
  63. # Set os-dependent files and extensions
  64. ifdef inlinux
  65. EXEEXT=
  66. REPLACE=mv -f
  67. CP=cp -f
  68. else
  69. EXEEXT=.exe
  70. REPLACE=move /y
  71. CP=cp -f
  72. endif
  73.  
  74. COMPILERDIR=$(BASEDIR)
  75. RTLDIR:=c:/pas/fpk/curver/rtl
  76.  
  77. # specify where units are.
  78. # This needs to be set correctly for the 'remake' target to work !
  79. ifndef UNITDIR
  80. UNITDIR=$(RTLDIR)/$(TARGET)
  81. ifeq ($(TARGET),dos)
  82. UNITDIR=$(RTLDIR)/dos/go32v1
  83. endif
  84. ifeq ($(TARGET),go32v2)
  85. UNITDIR=$(RTLDIR)/dos/go32v2
  86. endif
  87. endif
  88. # not def UNITDIR
  89.  
  90. # Where to install the executable program/link
  91. ifndef PROGINSTALLDIR
  92. ifdef inlinux
  93. PROGINSTALLDIR = /usr/bin
  94. else
  95. PROGINSTALLDIR = c:\pp\bin
  96. endif
  97. endif
  98.  
  99. # !!! Linux only
  100. # Where to install the _real_executable and support files
  101. ifndef LIBINSTALLDIR
  102. ifdef inlinux
  103. LIBINSTALLDIR=/usr/lib/fpc/0.99.5
  104. # for a.out
  105. # LIBINSTALLDIR=/usr/lib/ppc/aout/0.99.5
  106. else
  107. LIBINSTALLDIR=$(PROGINSTALLDIR)
  108. endif
  109. endif
  110.  
  111. # Where the .msg files will be stored
  112. ifndef MSGINSTALLDIR
  113. MSGINSTALLDIR=$(LIBINSTALLDIR)/msg
  114. endif
  115.  
  116. ifndef UNITINSTALLDIR
  117. ifdef inlinux
  118. UNITINSTALLDIR=$(LIBINSTALLDIR)/linuxunits
  119. else
  120. UNITINSTALLDIR=$(UNITDIR)
  121. endif
  122. endif
  123.  
  124. # !!! Linux only
  125. # GCCLIBPATH is wat is it on my PC... it MUST be set in the main Makefile
  126. ifndef GCCLIBPATH
  127. GCCLIBPATH=/usr/lib/gcc-lib/i486-linux/2.6.3
  128. endif
  129.  
  130. #####################################################################
  131. # When making diffs of the sources
  132. #####################################################################
  133.  
  134. # Diff program
  135. DIFF = diff
  136.  
  137. # Diff3 program
  138. DIFF3 = diff3
  139.  
  140. # Options to diff.
  141. DIFFOPTS = -b -c
  142.  
  143. # Directory where files are to make diffs with..
  144. ifdef inlinux
  145. DIFDIR = /usr/local/fpk/work/new/compiler
  146. else
  147. DIFDIR = h:/cvs/compiler
  148. endif
  149.  
  150. # Directory where reference files are for diff3
  151. ifdef inlinux
  152. REFDIR = /usr/local/fpk/dist/source/compiler
  153. else
  154. REFDIR = h:/myref/compiler
  155. endif
  156.  
  157. #####################################################################
  158. # End of configurable section. Do not edit after this line.
  159. #####################################################################
  160.  
  161. DIFFEXIST:=$(shell $(DIFF) --help)
  162.  
  163. # Used to avoid unnecessary steps in remake3
  164. ifdef DIFFEXIST
  165. ifdef OLDPP
  166. DIFFRESULT:=$(shell $(DIFF) $(OLDPP) $(PP))
  167. else
  168. DIFFRESULT=Not equal
  169. endif
  170. else
  171. DIFFRESULT=No diff program
  172. endif
  173.  
  174. # set correct defines (also needed by mkdep)
  175. PPDEFS:=-d$(CPU) -dGDB -dFPC
  176.  
  177. # Set the needed compiler options
  178. PPOPTS:=$(OPT) $(PPDEFS) -Sg
  179.  
  180. # Unitdir specified ?
  181. ifneq ("$(UNITDIR)", "")
  182. PPOPTS:=$(PPOPTS) -Up$(UNITDIR)
  183. endif
  184.  
  185. # Do we need the GCC library ?
  186. ifeq ($(LINK_TO_C),YES)
  187. PPOPTS:=$(PPOPTS) -Fg$(GCCLIBPATH)
  188. endif
  189.  
  190. # Create the whole compiler commandline
  191. COMPILER=$(PP) $(PPOPTS)
  192.  
  193. #####################################################################
  194. # Setup os-independent filenames
  195. #####################################################################
  196.  
  197. PPEXENAME=pp$(EXEEXT)
  198. EXENAME=ppc386$(EXEEXT)
  199. TEMPNAME=ppc$(EXEEXT)
  200. TEMPNAME1=ppc1$(EXEEXT)
  201. TEMPNAME2=ppc2$(EXEEXT)
  202. TEMPNAME3=ppc3$(EXEEXT)
  203. MAKEDEP=mkdep$(EXEEXT)
  204.  
  205. PASFILES:=$(shell ls *.pas)
  206. INCFILES:=$(shell ls *.inc)
  207. MSGFILES:=$(shell ls *.msg)
  208.  
  209. #####################################################################
  210. # Default makefile
  211. #####################################################################
  212.  
  213. .SUFFIXES: .pas $(EXEEXT) .ppu .dif .d3p .d3i .d3m .new
  214.  
  215. .PHONY : all clean info \
  216.      cycle remake remake3 \
  217.      install \
  218.      diff diff3 patch rtl toflor replacediff3 restorediff3 \
  219.      test rtlzip \
  220.  
  221. .pas.ppu:
  222.     $(COMPILER) $<
  223.  
  224. .pas$(EXEEXT):
  225.     $(COMPILER) $<
  226.  
  227. all : $(EXENAME)
  228.  
  229. ifndef DIFFRESULT
  230. next :
  231.     echo $(PP) and $(OLDPP)    are equal
  232.     $(CP) $(PP) $(EXENAME)
  233. else
  234. next :
  235.     $(MAKE) clean
  236.     $(MAKE) -C $(UNITDIR) clean
  237.     $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(PP)' all
  238.     $(MAKE) all
  239. endif
  240.  
  241. clean :
  242.     -rm -f *.o *.ppu *.s $(EXENAME)
  243.  
  244. #####################################################################
  245. # Info
  246. #####################################################################
  247.  
  248. info :
  249.     @echo - Target is $(TARGET)
  250.     @echo - Basedir is $(BASEDIR)
  251.     @echo - Pascal files are $(PASFILES)
  252.     @echo - Inc files are $(INCFILES)
  253.     @echo - Msg files are $(MSGFILES)
  254.  
  255. #####################################################################
  256. # Include depencies (linux only)
  257. #####################################################################
  258.  
  259. ifdef inlinux
  260. $(MAKEDEP) : $(RTLDIR)/utils/mkdep.pp
  261.     $(PP) $(RTLDIR)/utils/mkdep.pp
  262.     $(CP) $(RTLDIR)/utils/$(MAKEDEP) $(MAKEDEP)
  263.  
  264. dependencies : $(MAKEDEP)
  265.     $(MAKEDEP) pp.pas $(PPDEFS) '-A$$(COMPILER)' > depend
  266.  
  267. include depend
  268. endif
  269.  
  270. #####################################################################
  271. # Make targets
  272. #####################################################################
  273.  
  274. msgtxt.inc: errore.msg
  275.     msg2inc errore.msg msgtxt.inc msgtxt
  276.  
  277. optmsg.inc: optione.msg
  278.     msg2inc optione.msg optmsg.inc optiontxt
  279.  
  280. msg: msgtxt.inc optmsg.inc
  281.     
  282. # Make only the compiler
  283. ifdef inlinux
  284. $(EXENAME) : $(PPEXENAME)
  285.     $(COMPILER) pp.pas
  286.     $(REPLACE) $(PPEXENAME) $(EXENAME)
  287. else
  288. $(EXENAME) : $(PASFILES) $(INCFILES) $(MSGFILES)
  289.     $(COMPILER) pp.pas
  290.     $(REPLACE) $(PPEXENAME) $(EXENAME)
  291. endif
  292.  
  293. # This target remakes the units with the currently made version
  294. remake: $(EXENAME)
  295.     $(REPLACE) $(EXENAME) $(TEMPNAME)
  296.     $(MAKE) clean
  297.     $(MAKE) -C $(UNITDIR) clean
  298.     $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(TEMPNAME)' all
  299.     $(MAKE) 'PP=./$(TEMPNAME)' all
  300.  
  301. remake3: $(TEMPNAME3)
  302.     $(MAKE) 'PP=./$(TEMPNAME3)' 'OLDPP=./$(TEMPNAME2)' next
  303.     diff $(TEMPNAME3) $(EXENAME)
  304.  
  305. $(TEMPNAME1) : $(EXENAME)
  306.     $(REPLACE) $(EXENAME) $(TEMPNAME1)
  307.  
  308. $(TEMPNAME2) : $(TEMPNAME1)
  309.     $(MAKE) 'PP=./$(TEMPNAME1)' 'OLDPP=' next
  310.     $(REPLACE) $(EXENAME) $(TEMPNAME2)
  311.  
  312. $(TEMPNAME3) : $(TEMPNAME2)
  313.     $(MAKE) 'PP=./$(TEMPNAME2)' 'OLDPP=./$(TEMPNAME1)' next
  314.     $(REPLACE) $(EXENAME) $(TEMPNAME3)
  315.  
  316.  
  317. cycle:
  318.     $(MAKE) clean
  319.     $(MAKE) -C $(UNITDIR) clean
  320.     $(MAKE) -C $(UNITDIR)
  321.     $(MAKE) remake3
  322.  
  323. #####################################################################
  324. # Installation
  325. #####################################################################
  326.  
  327. install:
  328.     umask 022
  329.     strip ppc386
  330.     install -m 755 -d $(LIBINSTALLDIR)
  331.     install -m 755 ppc386 $(LIBINSTALLDIR)
  332.     ln -sf $(LIBINSTALLDIR)/ppc386 $(PROGINSTALLDIR)/ppc386
  333.     makecfg $(LIBINSTALLDIR)/samplecfg $(UNITINSTALLDIR) $(MSGINSTALLDIR) $(GCCLIBPATH)
  334.     install -m 755 -d $(MSGINSTALLDIR)
  335.     install -m 666 errore.msg $(MSGINSTALLDIR)
  336.     install -m 666 errorn.msg $(MSGINSTALLDIR)
  337.  
  338. #####################################################################
  339. # Diffs
  340. #####################################################################
  341.  
  342. SOURCEFILES = $(PASFILES) $(INCFILES) $(MSGFILES) Makefile
  343.  
  344. DIFFFILES = $(patsubst %.pas,%.dif,$(PASFILES)) \
  345.     $(patsubst %.inc,%.dif,$(INCFILES)) \
  346.     $(patsubst %.msg,%.dif,$(MSGFILES)) \
  347.     Makefil